package com.fyzk.activity.main;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ListView;

public class MainListView extends ListView{

	/**
	 * 触屏点x坐标
	 */
	private float xLast;
	/**
	 * 触屏点y坐标
	 */
	private float yLast;
	/**
	 * x方向滑动距离
	 */
	private float xDistance;
	/**
	 * y方向滑动距离
	 */
	private float yDistance;
	
	
	public MainListView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {

		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			xDistance = yDistance = 0f;  
            xLast = ev.getX();  
            yLast = ev.getY();  
            
            break;
			
		case MotionEvent.ACTION_MOVE:
			
			float curX = ev.getX();  
            float curY = ev.getY();  
              
            xDistance += Math.abs(curX - xLast);  
            yDistance += Math.abs(curY - yLast);  
            xLast = curX;  
            yLast = curY;  
              
            if(xDistance > yDistance){  
                return false;  
            }   
			
		case MotionEvent.ACTION_UP:
			
			break;
		default:
			break;
		}
		
		return super.onInterceptTouchEvent(ev);
	}
	
}
